var
u r w FK FL K Ltot Ctot Y I It
ut Kt Ct wt rt Yt Lt G x W;
varexo eps; 

parameters
beta alpha phi delta gamma chi rho_u Gss;

alpha   = 0.35999999999999998668;
beta    = 0.99173553719008245011;
phi     = 0.50000000000000000000;
delta   = 0.02500000000000000139;
gamma   = 1.00000000000000000000;
rho_u   = 0.10000000000000000555;
Gss     = 1.01802141333628326514;
chi     = 1.00000000000000000000;


model;

x = Ctot - (1/chi)*Ltot^(1+1/phi)/(1+1/phi); % equation 1
(x^-gamma) =  beta*(1+r(+1))*(x(+1)^-gamma); % equation 2
G = Gss*(1+u); % equation 3
I = K - (1-delta)*K(-1);  % equation 4
G  + Ctot + I = Y;  % equation 5
FL = (1 - alpha)*(K(-1)/Ltot)^alpha; % equation 6
FK = alpha*(K(-1)/Ltot)^(alpha-1)-delta; % equation 7
u = rho_u*u(-1) + eps;  % equation 8
Y = K(-1)^alpha*Ltot^(1-alpha);  % equation 9
Ltot =  (chi*w)^phi; % equation 10
r = FK;  % equation 11
w = FL;  % equation 12
W = log(x);  % equation 13
ut = 100*u;  % equation 14
Kt = 100*(K/64.33762664909913553402-1);  % equation 15
Ct = 100*(Ctot/3.33072557313063821738-1);  % equation 16
wt = 100*(w/2.44051137635560611017-1);  % equation 17
rt = 100*(r - (1/beta - 1));  % equation 18
Lt = 100*(Ltot/1.56221361418840731794-1);  % equation 19
Yt = 100*(Y/5.95718765269440009291-1);  % equation 20
It = 100*(I/1.60844066622747838835-1);  % equation 21
end;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

initval;

Ltot     = 1.56221361418840731794;
r     = 1/beta - 1;
w     = 2.44051137635560611017;
FK    = 0.00833333333333352577;
FL    = 2.44051137635560611017;
K     = 64.33762664909913553402;
x     = 2.05985887388916655283;
u     = 0;
Ctot  = 3.33072557313063821738;
Y     = 5.95718765269440009291;
I  = delta*K;
ut    = 0;
Kt    = 0;
Ct    = 0;
wt    = 0;
rt    = 0;
Lt    = 0;
Yt    = 0;
It    = 0;
G     = 1.01802141333628326514;
W     = 0.72263747263392885678;
end;

resid;

steady(nocheck);

shocks;
 var eps; stderr 0.05918829981020124614;
 end;
stoch_simul (order=1,irf=500) ut Yt Ct It Lt Kt W;